package cloud

import (
	"CloudInterface/common"
	"go.uber.org/zap"
	"io"
	"strings"
)

// 启动空闲流路的接口
func (CR *CloudClient) StartIdleStreamer(data common.StartIdleStreamerData) common.ResultData {
	CR.SetParams(data)
	defer CR.ResetPostParam(OriginalPostBody)

	url := baseUrl + "/open/v1/apply/idle_unstart_streamer"

	resp, err := CR.client.Post(url, "application/x-www-form-urlencoded", strings.NewReader(CR.ReqParams.Encode()))
	if err != nil {
		zap.L().Error("err in start idle streamer : " + err.Error())
	}
	defer resp.Body.Close()

	bytes, _ := io.ReadAll(resp.Body)

	startIdleResp := common.ResultData{Data: common.StartIdleStreamerResp{}}
	DecodeData(bytes, &startIdleResp)

	return startIdleResp
}
